package com.boot.config;

import com.boot.config.a.A1;
import com.boot.config.a.A2;
import com.boot.config.a.A3;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;

/**
 * @author
 * @date 2025-07-27
 * @Description
 */
@Configuration("otherConfig")
public class OtherConfig {

    // * **如果要一部分单实例， 一部分多实例怎么办？**
    //* 只需要在@Bean方法上配置上@Scope("prototype")
    @Bean
    @Scope("prototype")
    @Lazy
    public A1 a1() {
        return new A1();
    }

    @Bean
    public A2 a2() {
        A2 a2 = new A2();
        a2.setA(a1());//  测试a1 会产生多少个实例对象
        return a2;
    }

    @Bean
    public A3 a3() {
        A3 a3 = new A3();
        a3.setA(a1());//  测试a1 会产生多少个实例对象
        return a3;
    }
}
